package ltd.newbee.mall.config;

import com.paypal.core.PayPalEnvironment;
import com.paypal.core.PayPalHttpClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@RefreshScope
@Configuration
public class PaypalV2Config {

    @Value("${paypal.client.app}")
    private String clientId;

    @Value("${paypal.client.secret}")
    private String clientSecret;

    @Bean
    public PayPalEnvironment payPalEnvironment () {
        return new PayPalEnvironment.Sandbox(
                clientId,
                clientSecret
        );
    }

    @Bean
    public PayPalHttpClient payPalHttpClient () {
        return new PayPalHttpClient(payPalEnvironment());
    }

}
